package bb.lanxing.network;

import com.garmin.fit.MonitoringReader;
import com.tencent.connect.common.Constants;
import bb.lanxing.util.Log;
import java.util.Date;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;

public class TencentClient {
    public static OkHttpClient client = new OkHttpClient.Builder().build();

    public static void syncQQHealth(Callback callback, String str, String str2, int i, double d, int i2, double d2, int i3) {
        String str3 = i == 1 ? "https://openmobile.qq.com/v3/health/report_steps" : i == 2 ? "https://openmobile.qq.com/v3/health/report_running" : i == 3 ? "https://openmobile.qq.com/v3/health/report_riding" : "";
        Log.d("syncQQHealth distance = " + d + ", duration = " + i2 + ", speed = " + d2 + ", calories = " + i3);
        try {
            FormBody.Builder add = new FormBody.Builder().add("pf", Constants.SOURCE_QZONE).add("oauth_consumer_key", bb.lanxing.common.config.Constants.SOCIAL_QQ_APP_ID).add("openid", str2).add("access_token", str).add("time", String.valueOf(new Date().getTime() / 1000)).add(MonitoringReader.DISTANCE_STRING, String.valueOf(d)).add("duration", String.valueOf(i2)).add(MonitoringReader.CALORIE_STRING, String.valueOf(i3));
            if (i == 2 || i == 1) {
                add.add("steps", String.valueOf(d));
            }
            if (i == 3 || i == 1) {
                add.add("speed", String.format("%4.2f", d2));
            }
            Request build = new Request.Builder().url(str3).post(add.build()).build();
            Log.d("HttpClient", build.toString());
            client.newCall(build).enqueue(callback);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
